home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / languages / cleo.lzh / Cleo / inter / source / alloc.c next >
Encoding:
C/C++ Source or Header  |  1993-01-24  |  5.4 KB  |  183 lines

  1. /***************************************************************************
  2. *   Ce fichier, ainsi que tous les  modules  l'accompagnant, peut et  doit *
  3. * etre  copié GRATUITEMENT à la seule condition expresse de conserver      *
  4. * l'INTEGRALITE  du  Code Source, de  la documentation, et  des fichiers   *
  5. * annexes du package. Ce logiciel est Shareware, veuilez envoyer 100 FF à  *
  6. * l'auteur pour recevoir regulièrement les nouvelles versions.             *
  7. * Toute modification est INTERDITE sans l'autorisation écrite de l'auteur. *
  8. *            Tous droits réservés à M. DIALLO Barrou, Juillet 1992.        *
  9. ***************************************************************************/
  10.  
  11. #ifdef msdos
  12.    #include "include\\inter.h"
  13. #else
  14.    #include "include/inter.h"
  15. #endif
  16.  
  17. extern char *Char;
  18. extern long *Int;
  19. extern double *Real;
  20. extern char **String;
  21. extern Entete head;
  22.  
  23. extern char *Vchar;
  24. extern unsigned char *Vboolean;
  25. extern int  *Vinteger;
  26. extern double *Vreal;
  27. extern long *Vlongint;
  28. extern double *Vlongreal;
  29. extern char **Vstring;
  30. extern TAB *Varray;
  31. extern Point3d *Vpoint3d;
  32. extern Point2d *Vpoint2d;
  33. extern Rgb *Vrgb;
  34.  
  35. extern MY_CONST *stack;
  36. extern int stsz;
  37.  
  38. void AlloueStack(void)
  39. {
  40.              if (!( stack = (MY_CONST *)calloc(stsz, sizeof(MY_CONST))))
  41.                 {
  42.                   printf("Pas assez de memoire pour la Pile\n");
  43.                   EndInter();
  44.                 }
  45. }
  46.  
  47. void AlloueVars(void)
  48. {
  49.  
  50.         if (head.Vchar)
  51.         {
  52.           if (!( Vchar = (char *)calloc(head.Vchar, sizeof(char))))
  53.                 {
  54.                   printf("Pas assez de memoire pour les variables\n");
  55.                   EndInter();
  56.                 }
  57.         }
  58.  
  59.         if (head.Vboolean)
  60.         {
  61.               if (!( Vboolean = (unsigned char *)calloc(head.Vboolean, sizeof(unsigned char))))
  62.                 {
  63.                  printf("Pas assez de memoire pour les variables\n");
  64.                  EndInter();
  65.                 }
  66.         }
  67.  
  68.         if (head.Vinteger)
  69.         {
  70.             if (!( Vinteger = (int *)calloc(head.Vinteger, sizeof(int))))
  71.                 {
  72.                    printf("Pas assez de memoire pour les Variables\n");
  73.                    EndInter();
  74.                 }
  75.         }
  76.         if (head.Vlongint)
  77.         {
  78.             if (!( Vlongint = (long *)calloc(head.Vlongint, sizeof(long))))
  79.                 {
  80.                    printf("Pas assez de memoire pour les Variables\n");
  81.                    EndInter();
  82.                 }
  83.         }
  84.  
  85.         if (head.Vreal)  /* Stockage en plus des data sans types, donc seuil min =1000 */
  86.         {
  87.              if (!( Vreal = (double *)calloc(1000+head.Vreal, sizeof(double))))
  88.                 {
  89.                   printf("Pas assez de memoire pour les Variables\n");
  90.                   EndInter();
  91.                 }
  92.         }
  93.         if (head.Vlongreal)
  94.         {
  95.              if (!( Vreal = (double *)calloc(head.Vlongreal, sizeof(double))))
  96.                 {
  97.                   printf("Pas assez de memoire pour les Variables\n");
  98.                   EndInter();
  99.                 }
  100.         }
  101.  
  102.         if (head.Vstring)
  103.         {
  104.             if (!( Vstring = (char **)calloc(head.Vstring, sizeof(char *))))
  105.                 {
  106.                   printf("Pas assez de memoire pour les constantes Chaine\n");
  107.                   EndInter();
  108.                 }
  109.         }
  110.  
  111.         if (head.Varray)
  112.         {
  113.           if (!( Varray = (TAB *)calloc(head.Varray, sizeof(TAB))))
  114.                 {
  115.                   printf("Pas assez de memoire pour les constantes Tableaux\n");
  116.                   EndInter();
  117.                 }
  118.         }
  119.         if (head.Vpoint3d)
  120.         {
  121.           if (!( Vpoint3d = (Point3d *)calloc(head.Vpoint3d, sizeof(Point3d))))
  122.                 {
  123.                   printf("Pas assez de memoire pour les variables Point3d\n");
  124.                   EndInter();
  125.                 }
  126.         }
  127.         if (head.Vpoint2d)
  128.         {
  129.           if (!( Vpoint2d = (Point2d *)calloc(head.Vpoint2d, sizeof(Point2d))))
  130.                 {
  131.                   printf("Pas assez de memoire pour les variables Point2d\n");
  132.                   EndInter();
  133.                 }
  134.         }
  135.         if (head.Vrgb)
  136.         {
  137.           if (!( Vrgb = (Rgb *)calloc(head.Vrgb, sizeof(Rgb))))
  138.                 {
  139.                   printf("Pas assez de memoire pour les variables Rgb\n");
  140.                   EndInter();
  141.                 }
  142.         }
  143. }
  144.  
  145. void AlloueConst(void)
  146. {
  147.         if (head.Char)
  148.         {
  149.                 if (!( Char = (char *)calloc(head.Char, sizeof(char))))
  150.                 {
  151.                         printf("Pas assez de memoire pour les constantes\n");
  152.                         EndInter();
  153.                 }
  154.         }
  155.  
  156.         if (head.integer)
  157.         {
  158.                 if (!( Int = (long *)calloc(head.integer, sizeof(long))))
  159.                 {
  160.                         printf("Pas assez de memoire pour les constantes\n");
  161.                         EndInter();
  162.                 }
  163.         }
  164.  
  165.         if (head.real)
  166.         {
  167.                 if (!( Real = (double *)calloc(head.real, sizeof(double))))
  168.                 {
  169.                         printf("Pas assez de memoire pour les constantes\n");
  170.                         EndInter();
  171.                 }
  172.         }
  173.  
  174.         if (head.string)
  175.         {
  176.                 if (!( String = (char **)calloc(head.string, sizeof(char *))))
  177.                 {
  178.                         printf("Pas assez de memoire pour les constantes\n");
  179.                         EndInter();
  180.                 }
  181.         }
  182. }
  183.